<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>



<html>
	<head>
		<!-- Head -->
		<head>
			<title>预定</title>

			<!-- Meta-Tags -->
			<meta name="viewport" content="width=device-width, initial-scale=1">
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

			<script type="application/x-javascript">
				addEventListener("load", function() {
					setTimeout(hideURLbar, 0);
				}, false);

				function hideURLbar() {
					window.scrollTo(0, 1);
				};
			</script>
			<script type="text/javascript">
				function judge() {
					var startTime = new Date(document.getElementById("start").value);
					var endTime = new Date(document.getElementById("end").value);
					var lowPrice = Number(document.getElementById("low").value);
					var highPrice = Number(document.getElementById("high").value);
					var nowDate = new Date();

					if (nowDate > startTime && startTime.toDateString() != nowDate.toDateString()) {
						alert("入住时间不能早于今天！");
						return false;
					} else if (startTime > endTime) {
						alert("退房日期应大于入住日期,！");
						return false;
					} else if (lowPrice > highPrice) {
						alert("价格范围有误！");
						return false;
					} else
						return true;
				}
			</script>
			<!-- //Meta-Tags -->

			<!-- Style -->
			<link href="<c:url value="/css/bootstrap.css"/>" rel="stylesheet" type="text/css" media="all">
			<link href="<c:url value="/css/index.css"/>" rel="stylesheet" type="text/css" media="all">
			<link href="<c:url value="/css/adminBackground.css"/>" rel="stylesheet" type="text/css" media="all">
			


		</head>
		<!-- //Head -->


	<body style="font-size: 18px;">
	<div class="footer" style="margin: 0 auto;"></div>
		<h1>入&nbsp;住&nbsp;办&nbsp;理</h1>
<span class="return"><a href="/finallab/return" onclick="return confirm('返回主页？')" style="color: red;margin-top: 30px;">返回主页</a></span>
		<div style="width: 90%; margin: 0 auto;color: white;">
			<div class="selectt" style="">
				<form class="form-inline" action="<c:url value=" handleRoomSearch" />" onsubmit="return judge()">
				<div class="line1" style="margin: 0 auto;">
					<span>房间类型：</span>
					<select class="span2" style="display: inline;" name="roomType">
						<option value="单人间">- 单人间 -</option>
						<option value="双人间">- 双人间 -</option>
						<option value="三人间">- 三人间 -</option>
						<option value="四人间">- 四人间 -</option>
					</select>

					<span>&nbsp;&nbsp;&nbsp;入住日期：</span>
					<input id="start" type="date" style="width: 120px;float: none;" name="startTime" required="required" value="${startTime}" />
					<span style="font-weight: bolder; color: white">—</span>
					<input id="end" type="date" style="width: 120px;float: none;" name="endTime" required="required" value="${endTime}" />

					<span style="display: inline;">&nbsp;&nbsp;&nbsp;价格区间：</span>
					<input id="low" type="text" name="lowPrice" style="width: 50px;float: none;margin-top: 20px;background-color: white;height: 7px;color: black;" placeholder="最低价"
					 value="${lowPrice}" />
					<span style="font-weight: bolder;color: white;">—</span>
					<input id="high" type="text" name="highPrice" style="width: 50px;float: none;margin-top: 20px;background-color: white;height: 7px;color: black;" placeholder="最高价"
					 value="${highPrice}" />
					<button type="submit" class="btn btn-primary">查找</button>
				</div>
				</form>
			</div>

			<c:choose>
				<c:when test="${empty roomList||roomList==null}">
					<h3 style="color:red;font-size:bolder;text-align: center">${msg==null?"请填写查询条件":msg}</h3>
				</c:when>
				<c:otherwise>
					<div style="margin: 0 auto;">
						<table class="orders-table table">
							<thead>
								<tr>
									<th style="color: blue;">房间</th>
									<th style="color: blue;" class="actions">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;价格</th>
								</tr>
							</thead>
							<tbody style="background-color: #999;">
								<c:forEach items="${roomList}" var="room">
									<tr>
										<td>
											<span style="color: yellow; font-weight: bolder;user-select:none;">房间号：#${room.number}&nbsp;&nbsp;</span>
											<span class="label label-success" style="user-select:none;">${room.type}</span>
											<br /><br />
											<span class="meta">${room.decription}</span>
										</td>

										<td class="actions">
											<span class="btn-small" data-toggle="modal" style="color: red;font-size: 16px;">￥${room.price}</span>

											<a class="btn btn-small btn-primary" style="user-select:none;" href="<c:url value=" handle?startTime=${startTime}&endTime=${endTime}&number=${room.number}" />">办理入住</a>

										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</c:otherwise>
			</c:choose>
		</div>
	</body>
</html>
